package com.jt.www.enums.issue;

import org.apache.commons.lang3.StringUtils;

/**
 * 支付方式对接大平台的code
 */
public enum PayChannelEnum {

    WEIXIN("weixin", "00"),
    VBAO("vbao", "08"),
    ALI("ali", "01"),
    ALLIN("allin", "02");

    private String channel;
    private String code;

    PayChannelEnum(String channel, String code) {
        this.channel = channel;
        this.code = code;
    }

    /**
     * 通过channel得到cdoe
     *
     * @param channel
     * @return
     */
    public static String getCodeByChannel(String channel) {
        if (StringUtils.isBlank(channel)) {
            return "";
        }
        for (PayChannelEnum payChannelEnum : PayChannelEnum.values()) {
            if (payChannelEnum.channel.equals(channel)) {
                return payChannelEnum.getCode();
            }
        }
        return "";
    }

    public String getChannel() {
        return channel;
    }

    public String getCode() {
        return code;
    }
}
